/// 过滤器
class Filter {
  static String getDate(String dateOriginal) {
    //现在的日期
    DateTime today = DateTime.now();
    //今天的23:59:59
    DateTime standardDate = DateTime(today.year, today.month, today.day, 23, 59, 59);
    //传入的日期与今天的23:59:59秒进行比较
    Duration diff = standardDate.difference(DateTime.parse(dateOriginal));
    if (diff < Duration(days: 1)) {
      // 今天 09:20
      return dateOriginal.substring(11, 16);
    } else if (diff >= Duration(days: 1) && diff < Duration(days: 2)) {
      // 昨天 昨天09:20
      return "昨天 " + dateOriginal.substring(11, 16);
    } else {
      // 昨天之前 2019-01-23 09:20
      return dateOriginal.substring(0, 16);
    }
  }

  /// 99+ 超出一定数量的数据转化为 某某+
  static String maxToAdd(num val, double max) {
    if (val > max) {
      if (val.runtimeType == double) {
        return "$max+";
      } else {
        return "${max.toInt()}+";
      }
    } else {
      return val.toString();
    }
  }

  /// 过滤敏感文字为*
  static String txt(String txt) {
    // RegExp reg = RegExp(r'[0-9a-zA-z一二三四五六七八九十百千万①②③④⑤⑥⑦⑧⑨⑩]|微信');
    // return txt.replaceAll(reg, '*');
    return txt;
  }
}
